export default {
  install(app, options) {
    const components = require.context('./', true, /\.vue$/)
    const getName = str => {
      const regex = /\/(\w+)\//
      const match = str.match(regex)
      const componentName = match ? match[1] : ''
      return componentName
    }
    components.keys().forEach(item => {
      app.component(getName(item), components(item).default)
    })
  }
}
